<?php
@require_once('class_page.php');
class checkGetData extends page
{
	private $content;
	private $title;
	function __construct($db)
	{
		$connect=new connect($db);
	}
	function error()
	{
		$this->title='Неверный адрес!';
		$this->content='
		<center><h1>
		Неверный адрес<br /></h1>
		<a href="index.php">На главную</a>
		</center>
		';
		parent::__construct();
		exit;
	}
	function safetyCheck($value)
	{
		$value=@ strip_tags($value);
		$value=htmlspecialchars($value);
		$value=addslashes($value);
		$value=str_replace('\'', '', $value);
		return $value;
	}
	function checkCity($city)
	{
		$city=$this->safetyCheck($city);
		$query="SELECT * FROM $city LIMIT 1";
		//echo $query;
		$res=mysql_query($query) or $this->error();
	}
	function checkTableId($table, $id)
	{
		$table=$this->safetyCheck($table);
		$id=$this->safetyCheck($id);
		$query="SELECT * FROM $table WHERE id='$id'";
		//echo $query;
		$res=mysql_query($query) or $this->error();
		$row=mysql_num_rows($res);
		if(!$row)$this->error();
	}
	function checkTableElement($table, $element, $elementName)
	{
		$table=$this->safetyCheck($table);
		$element=$this->safetyCheck($element);
		$query="SELECT * FROM $table WHERE ".$elementName."='$element'";
		$res=mysql_query($query) or $this->error();
		$row=mysql_num_rows($res);
		if(!$row)$this->error();

	}
	function title()
	{
		echo $this->title;
	}
	function maincontent()
	{
		echo $this->content;
	}
}
?>